﻿SELECT 
	B.AREA_MGR, 
	B.ACCT_MGR, 
	A.START_DT, 
	A.BAN, 
	A.PRODUCT, 
	A.DIRECTION, 
	A.ELU_ID, 
	A.SALES_CHANNEL_CD, 
	A.FEATURE, 
	A.ORDER_ID, 
	A.TRAC_ID, 
	A.REGION, 
	A.MARKET, 
	A.PROGRAM, 
	A.NATIONAL_ID, 
	COALESCE(C.WIRE_CENTER,'') WIRE_CENTER, 
	COALESCE(C.LUID,'') LUID, 
	COALESCE(C.DISTRIBUTION_AREA_CD,'') DA_CD 
FROM 
	MIS.ACC_RAW 
	A 
	INNER JOIN 
	MIS.ACC_BASE_DATA 
	B 
	ON A.TRAC_ID=B.TRAC_ID 
	LEFT OUTER JOIN 
	MIS.RX3446_GREEN 
	C 
	ON A.ELU_ID=C.EXTERNAL_LIVING_UNIT_ID 
WHERE 
	A.START_DT BETWEEN 1{0:yyMMdd} AND 1{1:yyMMdd} {2} 
ORDER BY 
	B.AREA_MGR, B.ACCT_MGR, A.START_DT, A.BAN